<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/4
  Time: 19:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>详情页面</title>
    <style>
        #one {
            text-decoration: none;
            color: red;
        }
        #two {
            color: brown;
        }
        #three {
            margin-left: 150px;
        }
    </style>
</head>
<body>
<%--    在主页面点击文章的详情按钮后就进入到详情页面，并在此显示文章的标题和内容
        然后在这多加了一步是点击标题可以返回主页面
--%>
    <section>
        <header>
            <h3><a href="${pageContext.request.contextPath}/post/list" id="one">文章标题：${post.title}</a></h3>
        </header>
        <div>
            <p id="two">文章内容：${post.content}</p>
        </div>
    </section>
    <hr>

    <section>
        <c:forEach items="${comments}" var="comment" varStatus="s">
<%--            渲染评论列表--%>
            <div>
                TOP: ${s.count} 作者：${comment.author}
<%--                删除按钮--%>
                <a href="${pageContext.request.contextPath}/comment/del?id=${comment.id}" id="three">删除</a>
            </div>
            <div>
                <p>评论内容：${comment.content}</p>
            </div>
            <div id="time">
                <span>
                    评论时间：${comment.created}
                </span>
            </div><br><br>
        </c:forEach>
    </section>

    <section>
        <form method="post" action="${pageContext.request.contextPath}/comment/add">
            <input type="hidden" name="postId" value="${post.id}">
            <label>
                <span>姓名：</span>
                <input name="author">
            </label><br><br>
            <label>
                <span>评论内容：</span>
                <textarea name="content"></textarea>
            </label><br><br>
            <div>
                <button>提交评论</button>
            </div>
        </form>
    </section>
</body>
</html>
